// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   INTImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.QTY;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;

//import oracle.xml.parser.v2.XMLDocument;
//import oracle.xml.parser.v2.XMLElement;
//import oracle.xml.parser.v2.XMLNode;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, BLImpl, CSImpl, NullFlavorImpl, 
//            STImpl, TYPEImpl

public class INTImpl extends ANYImpl
    implements INT
{

    public static final String RCS_ID = "$Header: INTImpl.java 115.29 2005/09/16 09:23:11 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: INTImpl.java 115.29 2005/09/16 09:23:11 amchanda noship $", "oracle.apps.ctb.hl7.types.common");
    private long mValue;
    private static final INT nullNI = new INTImpl(CSImpl.valueOf("NI"));
    private static final INT nullOTH = new INTImpl(CSImpl.valueOf("OTH"));
    private static final INT nullNINF = new INTImpl(CSImpl.valueOf("NINF"));
    private static final INT nullPINF = new INTImpl(CSImpl.valueOf("PINF"));
    private static final INT nullUNK = new INTImpl(CSImpl.valueOf("UNK"));
    private static final INT nullASKU = new INTImpl(CSImpl.valueOf("ASKU"));
    private static final INT nullNAV = new INTImpl(CSImpl.valueOf("NAV"));
    private static final INT nullMSK = new INTImpl(CSImpl.valueOf("MSK"));
    private static final INT nullNA = new INTImpl(CSImpl.valueOf("NA"));
    private static final INT nullNASK = new INTImpl(CSImpl.valueOf("NASK"));

    protected INTImpl(long l)
    {
        mValue = l;
    }

    protected INTImpl(CS cs)
    {
        super(true, cs);
        mValue = 0L;
    }

    public static INT valueOf(long l)
    {
        return new INTImpl(l);
    }

    public static INT nullINT()
    {
        return new INTImpl(((CS) (null)));
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof INT))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            INT int1 = (INT)any;
            return BLImpl.valueOf(mValue == int1.longValue());
        }
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.INT;
    }

    public BL lessOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "lesOrEqual");
    }

    public BL compares(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "compares");
    }

    public TYPE diffType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.INT;
    }

    public QTY minus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "minus");
    }

    public QTY plus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "plus");
    }

    public BL isZero()
    {
        if(isNull().isTrue())
            return BLImpl.nullBL(NullFlavorImpl.NI);
        else
            return BLImpl.valueOf(mValue == 0L);
    }

    public BL lessThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "lessThan");
    }

    public BL greaterOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "greaterOrEqual");
    }

    public BL greaterThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("INT", "greaterThan");
    }

    public INT successor()
    {
        if(isNull().isTrue())
            return nullINT(NullFlavorImpl.NI);
        else
            return valueOf(mValue + 1L);
    }

    public INT times(INT int1)
    {
        throw ANYImpl.newUnsupportedException("INT", "times");
    }

    public INT predecessor()
    {
        if(isNull().isTrue())
            return nullINT(NullFlavorImpl.NI);
        else
            return valueOf(mValue - 1L);
    }

    public INT negated()
    {
        if(isNull().isTrue())
            return nullINT(NullFlavorImpl.NI);
        else
            return valueOf(-mValue);
    }

    public BL isNegative()
    {
        if(isNull().isTrue())
            return BLImpl.nullBL(NullFlavorImpl.NI);
        else
            return BLImpl.valueOf(mValue < 0L);
    }

    public BL nonNegative()
    {
        if(isNull().isTrue())
            return BLImpl.nullBL(NullFlavorImpl.NI);
        else
            return BLImpl.valueOf(mValue >= 0L);
    }

    public INT dividedBy(INT int1)
    {
        throw ANYImpl.newUnsupportedException("INT", "dividedBy");
    }

    public INT remainder(INT int1)
    {
        throw ANYImpl.newUnsupportedException("INT", "remainder");
    }

    public BL isOne()
    {
        if(isNull().isTrue())
            return BLImpl.nullBL(NullFlavorImpl.NI);
        else
            return BLImpl.valueOf(mValue == 1L);
    }

    public ST literal()
    {
        if(isNull().isTrue())
            return STImpl.nullST(nullFlavor());
        else
            return STImpl.valueOf(toString());
    }

    public long longValue()
    {
        return mValue;
    }

    public int intValue()
    {
        return (int)mValue;
    }

    public short shortValue()
    {
        return (short)(int)mValue;
    }

    public byte byteValue()
    {
        return (byte)(int)mValue;
    }

    public String toString()
    {
        if(isNull().isTrue())
            return "<Null:" + nullFlavor().toString() + ">";
        else
            return String.valueOf(mValue);
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
            i = 37 * i + (int)(mValue ^ mValue >>> 32);
        return i;
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//            xmlelement.setAttribute("value", (new Long(longValue())).toString());
//            return (new XMLNode[] {
//                xmlelement
//            });
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

    public static INT nullINT(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
